<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'modify.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <div align="center"><h1>修改密码</h1></div>
  	<form action="modify" method="post" id="myform" enctype="multipart/form-data">
    	<input type="hidden" name="userid" value="${info.userid }"/>
    <table border="1" align="center">
    	<tr>
    		<td>账号</td>
    		<td><input name="userAccount" value="${info.userAccount }"/><span id="a"></span></td>
    	</tr>
    	<tr>
    		<td>密码</td>
    		<td><input type="password" name="oldpassword" value="${info.password }"/><span id="b"></span></td>
    	</tr>
    	<tr>
    		<td>新密码</td>
    		<td><input type="password" name="password"/><span id="c"></span></td>
    	</tr>
    	<tr>
    		<td>邮箱</td>
    		<td><input name="email" value="${info.email }"/><span id="d"></span></td>
    	</tr>
    	<tr>
    		<td>部门</td>
    		<td>
    			<select name="deptId">
    					<option value="0">请选择</option>
    					<c:forEach var="list" items="${list}">
    						<option <c:if test="${info.deptId == list.deptId }">selected</c:if> value="${list.deptId }">${list.deptName }</option>
    					</c:forEach>
    				</select>
    				<span id="e"></span>
    		</td>
    	</tr>
    	<tr>
    		<td colspan="2"><input type="submit" value="修改"/>
    		<a href="index.jsp"><input type="button" value="取消"/></a></td>
    	</tr>
    </table>
    </form>
  </body>
  <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
  <script type="text/javascript">
  	$(function(){
  		$("#myform").submit(function(){
  		 	var a = $("[name=password]").val();
  		 	var b = $("[name=chePassword]").val();
  			if(b == a){
  				$("#c").html("新密码不能与原密码一样");
  				return false;
  			}
  			if(a == null){
  				a.val(b);
  			}
  		});
  	});
  </script>
</html>
